﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Telerik.Windows.Controls;

namespace Chaotic.Core.Extension
{
    public static  class MessageBoxExtension
    {
        public static void Show(string msg)
        {
            RadWindow.Alert(msg);
        }

        public static void ShowError(string msg)
        {
            RadWindow.Alert(new Telerik.Windows.Controls.DialogParameters()
            {
                Content = msg,
                Owner = Application.Current.MainWindow,
                Header = "错误",
                OkButtonContent = "确定",
            });
        }

        public static bool ShowConfirm(string msg,string header,string okContent = "确定",string canelContent = "取消")
        {
            bool isConfirm = false;
            RadWindow.Confirm(new Telerik.Windows.Controls.DialogParameters()
            {
                Content = msg,
                Header = header,
                Owner = Application.Current.MainWindow,
                OkButtonContent = okContent,
                CancelButtonContent = canelContent,
                Closed = (s, e) =>
                {
                    if (e.DialogResult == true)
                    {
                        // 确认操作
                        isConfirm = true;
                    }
                    else
                    {
                        // 取消操作
                        isConfirm = false;
                    }
                }
            });
            return isConfirm;
        }
    }
}
